package com.juc.scheduledExecutorService.scheduledExecutorService10;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Run2 {

	/**
	 * setContinueExistingPeriodicTasksAfterShutdownPolicy(true)
	 * 作用当传入true时scheduleAtFixedRate()方法或
	 *  scheduleWithFixedDelay()方法时，如果调用ScheduledThreadPoolExecutor
	 *  对象的shutdown()方法，任务会继续运行，传入false时任务不运行，进程销毁
	 *  
	 */
	public static void main(String[] args) {
		ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(10);
		Runnable runnable1 = new MyRunnable("A");
		executor.scheduleAtFixedRate(runnable1, 1, 2, TimeUnit.SECONDS);
		executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
		executor.shutdown();
		System.out.println("执行了shutdown ！");
	}
}
